import Vue from 'vue'
import Vuex from 'vuex'
import cart from './modules/cart.js'
import user from './modules/user.js'

Vue.use(Vuex)

export default new Vuex.Store({
  modules: {
    cart,
    user
  },
  getters: {
    sum (state) {
      return state.cart.cartList.reduce((prev, next) => {
        return next.flag ? prev + next.num : prev + 0
      }, 0)
    }
  }
})
